const express = require('express');

const morgan = require('morgan');   
const cors = require('cors');       //为客户端提供跨域资源请求
const app = express();
const router = require('./router');
const error = require('./middleware/error'); //统一处理错误中间件

app.use(express.json());
app.use(express.urlencoded());
app.use(cors());
app.use(morgan('dev'));

app.use('/api', router);

const PORT = process.env.port || 7070;



//挂载错误处理中间件
app.use(error());
app.listen(PORT, () => {
    console.log(`服务器${PORT}启动成功！！！！`)
})